package me.jessyan.mvparms.demo.di.module.home;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.PopupWindow;

import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.widget.CustomPopupWindow;

import dagger.Module;
import dagger.Provides;

import me.jessyan.mvparms.demo.R;
import me.jessyan.mvparms.demo.mvp.contract.home.HomeContract;
import me.jessyan.mvparms.demo.mvp.model.home.HomeModel;


@Module
public class HomeModule {
    private HomeContract.View view;

    /**
     * 构建HomeModule时,将View的实现类传进来,这样就可以提供View的实现类给presenter
     *
     * @param view
     */
    public HomeModule(HomeContract.View view) {
        this.view = view;
    }

    @ActivityScope
    @Provides
    HomeContract.View provideHomeView() {
        return this.view;
    }

    @ActivityScope
    @Provides
    HomeContract.Model provideHomeModel(HomeModel model) {
        return model;
    }

    @ActivityScope
    @Provides
    int [] provideTabIcon(){
        return new int[]{R.drawable.tab_life,R.drawable.tab_brand,R.drawable.tab_shppoing_card,R.drawable.tab_mine};
    }

    @ActivityScope
    @Provides
    String [] provideTabStr(){
        return new String[] {"Life","品牌馆","购物卡","我的"};
    }

    @ActivityScope
    @Provides
    CustomPopupWindow providePop(){
        View content = LayoutInflater.from(view.getActivity())
                .inflate(R.layout.pop_home_grandma,null);
        CustomPopupWindow popupWindow = CustomPopupWindow.builder()
                .isFocus(true)
                .isOutsideTouch(true)
                .isWrap(true)
                .contentView(content)
                .customListener(view.getActivity()).build();
        //PopupWindow全屏显示
        popupWindow.setClippingEnabled(false);
        return popupWindow;
    }
}